﻿using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VoL.Domain.IServices.WorkforceManage;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.WorkforceManage
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkforceController : ControllerBase
    {
        /// <summary>
        /// 人员分组
        /// </summary>
        private readonly INurseGroupService _nurseGroupService;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="nurseGroupService">人员分组</param>
        public WorkforceController(INurseGroupService nurseGroupService)
        {
            _nurseGroupService = nurseGroupService;
        }

        /// <summary>
        /// 添加人员分组信息
        /// </summary>
        /// <param name="nurseGroup">集合</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<int> AddNurseGroup([FromBody] NurseGroup nurseGroup)
        {
            var i = await _nurseGroupService.AddNurseGroup(nurseGroup);
            return i;
        }

        /// <summary>
        /// 获取人员分组信息
        /// </summary>
        /// <param name="nurseGroup">集合</param>
        /// <returns>返回任务</returns>
        [HttpGet]
        public IQueryable<NurseGroup> GetAllNurseGroups()
        {
            var nursegrouplist = _nurseGroupService.GetAllNurseGroups();
            return nursegrouplist;
        }

        /// <summary>
        ///删除人员分组信息
        /// </summary>
        /// <param name="nurseGroup">集合</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<int> DeleteNurseGroup([FromBody] NurseGroup nurseGroup)
        {
            var i = await _nurseGroupService.DeleteNurseGroup(nurseGroup);
            return i;
        }

        /// <summary>
        /// 编辑人员分组信息
        /// </summary>
        /// <param name="nurseGroup">集合</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<int> UpdateNurseGroup([FromBody] NurseGroup nurseGroup)
        {
            var i = await _nurseGroupService.UpdateNurseGroup(nurseGroup);
            return i;
        }
    }
}
